//
//  ClickCollectionViewController.m
//  MyProject
//
//  Created by dllo on 15/11/4.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "ClickCollectionViewController.h"
#import "GoodsLabelTableViewCell.h"
#import "GoodImageViewTableViewCell.h"
#import "UIImageView+WebCache.h"

@interface ClickCollectionViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end

@implementation ClickCollectionViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.tableView registerNib:[UINib nibWithNibName:@"GoodImageViewTableViewCell" bundle:nil] forCellReuseIdentifier:@"name"];
    
    [self.tableView registerNib:[UINib nibWithNibName:@"GoodsLabelTableViewCell" bundle:nil] forCellReuseIdentifier:@"label"];

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 2;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        GoodImageViewTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"name"];
        [cell.GoodImage sd_setImageWithURL:[NSURL URLWithString:self.collect.photo] placeholderImage:[UIImage imageNamed:@"lovebeijing.png"]];
        return cell;
    }
    else{
        GoodsLabelTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"label"];
        cell.messageLable.text = self.collect.title;
        //cell.messageLable.backgroundColor = [UIColor redColor];
        NSLog(@"%@",self.collect.title);
        return cell;
    }
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        return self.view.bounds.size.width;
    }
    
    else{
        CGRect rect = [self.collect.title boundingRectWithSize:CGSizeMake(self.view.bounds.size.width - 20, 10000) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName :[UIFont systemFontOfSize:17]} context:nil];
        return  rect.size.height+100;
    }
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
